<div class="rsidebar">
<ul>
	<?php if ( function_exists('dynamic_sidebar') && dynamic_sidebar(2) ) : else : ?>	

	<li><img src="http://www.xys-reader.org/blogs/wp-content/blogs/44/uploads//fangzhouzi_portait.jpeg"></li>


<?php if (function_exists('get_highest_rated') && 0): ?>
    <li><h2><?php _e("Highly Rated"); ?></h2>
   <ul>
      <?php get_highest_rated(); ?>
   </ul>
  </li>
<?php endif; ?>


    <li><h2>Recent Post</h2>
    <ul>
    <?php wp_get_archives('type=postbypost&limit=8'); ?>
    </ul>
    </li>

    <li><h2>Recent Comments</h2>
		
				     <?php
    global $wpdb,$blog;

    $sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,
    comment_post_ID, comment_author, comment_date_gmt, comment_approved,
    comment_type,comment_author_url,
    SUBSTRING(comment_content,1,52) AS com_excerpt
    FROM $wpdb->comments
    LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
    $wpdb->posts.ID)
    inner JOIN $wpdb->post2cat ON ($wpdb->post2cat.post_id = $wpdb->posts.ID)
    inner JOIN $wpdb->categories ON ($wpdb->post2cat.category_id = $wpdb->categories.cat_ID)
    WHERE comment_approved = '1' AND comment_type = '' AND
    post_password = ''
    and $wpdb->categories.blog = $blog 
    ORDER BY comment_date_gmt DESC
    LIMIT 10";
    $comments = $wpdb->get_results($sql);

    $output = $pre_HTML;
    $output .= "\n<ul>";
    mb_internal_encoding("UTF-8");//PEAK
    if($comments){
    foreach ($comments as $comment) {

    $output .= "\n<li>".strip_tags($comment->comment_author)
    .":" . "<a href=\"" . get_permalink($comment->ID) .
    "#comment-" . $comment->comment_ID . "\" title=\"on " .
    $comment->post_title . "\">" . strip_tags(mb_substr($comment->com_excerpt,0,20))
    ."</a></li>";

    }
    }
    $output .= "\n</ul>";
    $output .= $post_HTML;

    echo $output;?>

	
			</li>
   	<?php
	$access=get_settings("blog_access");
	if($access < 5) $access=0;
	$access++;
	//if($_GET["update"]==1) $access=850641;
  	update_option("blog_access",$access);
    	echo "<li><h2>ACCESS: $access </h2></li>\n";
	?>
 
  <?php endif; ?>

  </ul>
</div>
